package IO;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-08-26
 * Time: 16:17
 */
public class Demo5 {
    public static void main(String[] args) {
        try(InputStream inputStream = new FileInputStream("./text.txt")) {
            while(true) {
                byte[] buffer = new byte[1024];
                int n = inputStream.read(buffer);
                if(n == -1) {
                    break;
                }
                //n返回读了多少个字节数。
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%x\n",buffer[i]);
                }
            }
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}
